let url2 = new URL("./image/diving.png",window.location.href)
// 设置一个图标对象
var icon = {
   // 图标类型，现阶段只支持 image 类型
   type: 'image',
   // 图片 url
   image: url2,
   // 图片尺寸
   size: [64, 30],
   // 图片相对 position 的锚点，默认为 bottom-center
   anchor: 'center',
};
var textStyle = {
    fontSize: 12,
    fontWeight: 'normal',
    fillColor: '#22886f',
    strokeColor: '#fff',
    strokeWidth: 2,
    fold: true,
    padding: '2, 5',
};
var waterLabelsData = [
    {
        name: '天津海昌极地海洋公园潜水体验',
        position: [117.662097, 39.008993],
        zooms: [10, 20],
        opacity: 1,
        zIndex: 10,
        fold: true,
        icon,
        text: {
            // 要展示的文字内容
            content: '天津海昌极地海洋公园潜水体验',
            // 文字方向，有 icon 时为围绕文字的方向，没有 icon 时，则为相对 position 的位置
            direction: 'right',
            // 在 direction 基础上的偏移量
            offset: [-20, -5],
            // 文字样式
            style: {
                // 字体大小
                fontSize: 12,
                // 字体颜色
                fillColor: '#22886f',
                //
                strokeColor: '#fff',
                strokeWidth: 2,
                fold: true,
                padding: '2, 5',
            }
        }
    },

    {
        name: '潜心潜意人鱼潜水俱乐部',
        position: [117.209308, 39.062719],
        zooms: [10, 20],
        opacity: 1,
        zIndex: 16,
        icon,
        text: {
            content: '潜心潜意人鱼潜水俱乐部',
            direction: 'right',
            offset: [-20, -5],
            style: textStyle
        }
    },
    {
        name: 'PlayMaster玩主·水鬼自由潜水俱乐部',
        position: [117.177609, 39.071469],
        zooms: [10, 20],
        opacity: 1,
        zIndex: 16,
        icon,
        text: {
            content: 'PlayMaster玩主·水鬼自由潜水俱乐部',
            direction: 'right',
            offset: [-20, -5],
            style: textStyle
        }
    },
    {
        name: '泡泡堂潜水',
        position: [117.171815, 39.075535],
        zooms: [10, 20],
        opacity: 1,
        zIndex: 16,
        icon,
        text: {
            content: '泡泡堂潜水',
            direction: 'right',
            offset: [-20, -5],
            style:textStyle
        }
    },
    {
        name: '海天逸帆潜水游泳俱乐部',
        position: [117.144413, 39.113752],
        zooms: [10, 20],
        opacity: 1,
        zIndex: 16,
        icon,
        text: {
            content:'海天逸帆(融创中心春丰园店)',
            direction:'right',
            offset:[-20,-5],
            style:textStyle
        }
    },
    {
      name:'海天逸帆潜水游泳俱乐部',
      position:[117.189665,39.135635],
      zooms:[10,20],
      opacity:1,
      zIndex:16,
      icon,
      text:{
          content:'海天逸帆潜水游泳俱乐部',
          direction:'right',
          offset:[-20,-5],
          style:textStyle
      }
    },
    {
      name:'NAMI自由潜水俱乐部',
      position:[117.188638,39.131074],
      zooms:[10,20],
      opacity:1,
      zIndex:16,
      icon,
      text:{
          content:'NAMI自由潜水俱乐部',
          direction:'right',
          offset:[-20,-5],
          style:textStyle
      }
    },
    {
      name:'蒂亚摩潜水俱乐部',
      position:[117.211501,39.080183],
      zooms:[10,20],
      opacity:1,
      zIndex:16,
      icon,
      text:{
          content:'蒂亚摩潜水俱乐部',
          direction:'right',
          offset:[-20,-5],
          style:textStyle
      }
    },
    {
      name:'闹海潜水中心',
      position:[117.109285,39.259192],
      zooms:[10,20],
      opacity:1,
      zIndex:16,
      icon,
      text:{
          content:'闹海潜水中心',
          direction:'right',
          offset:[-20,-5],
          style:textStyle
        }
     }
]
var map = new AMap.Map('container', {
    zoom: 10,
    center: [117.201509,39.085318],
    showIndoorMap: false,
});

var watermarkers = [];
var allowCollision = false;
var waterlayer = new AMap.LabelsLayer({
zooms: [3, 20],
zIndex: 1000,
// collision: false,
// 设置 allowCollision：true，可以让标注避让用户的标注
allowCollision,
});
waterlayer.add(watermarkers);
// 图层添加到地图
map.add(waterlayer);

//初始化 labelMarker
for (var i = 0; i < waterLabelsData.length; i++) {
    var curData = waterLabelsData[i];
    curData.extData = {
        index: i
    };

    var waterlabelMarker = new AMap.LabelMarker(curData);

    watermarkers.push(waterlabelMarker);

}
// 将 marker 添加到图层
// waterlayer.add(watermarkers);


   


